/*
 * gpio.c
 *
  *	Project 4
 *  Created on: Mar 1, 2013
 *      Engineers: George Tkachuk & Brentton Garber
 *      Emails: 	gtkachuk@asu.edu btgarber@asu.edu 
 *      CSE 325: Embedded microprocessor Systems
 *      Spring 2013
 */
#include "common.h"

int gpio_port_tc_get_pin_state(int p_pin)
{
	return ((MCF_GPIO_SETTC >> p_pin) % 2);
	// Accesses the SETTC register and returns the state of pin p_pin (0 or 1).
}

void gpio_port_tc_init()
{
	MCF_GPIO_PTCPAR &= 0x0;
	MCF_GPIO_DDRTC |= 0xF;
	// Configures PTCPAR and DDRTC so port TC is in GPIO function and the pin data
	// direction is output.
}

void gpio_port_tc_set_pin_state(int p_pin ,int p_state)
{
	if(p_state == 1)
	{
		MCF_GPIO_SETTC |= (1 << p_pin);
	}
	else 
		MCF_GPIO_CLRTC &= ~(1 << p_pin);
	
	// Accesses the SETTC register to set the state of pin p_pin to p_state
}
